#include "kdcdisc.h"

#include <KLocale>
#include <KIcon>

#include <kdclib.h>

KDCDisc::KDCDisc( KDC::DiscType aType ) : KDCObject( KDC::Disc ), pDiscType( aType ), pMenu( NULL )
{
	pSettings = new KDCDiscSettings( this );
}

KDCDisc::~KDCDisc()
{
	deletePtr( pMenu );
	deletePtr( pSettings );
}
	
KDC::DiscType KDCDisc::type() const
{
	return pDiscType;
}
	
QString KDCDisc::title() const
{
	return i18n( "Disc" ) + " " + toString( type() );
}

KIcon KDCDisc::icon() const
{
	switch ( type() )
	{
		case KDC::DVD: return KIcon("media-optical-dvd");
		case KDC::BLURAY: return KIcon("media-optical-blu-ray");
	}
	return KIcon("media-optical");
}
	
void KDCDisc::add( KDCVTS *aVts )
{
	aVts->setParent( this );
	pVts.append( aVts );
}

void KDCDisc::add( KDCMenu *aMenu )
{
	aMenu->setParent( this );
	pMenu = aMenu;
}

void KDCDisc::add( KDCMovie *aMovie )
{
	aMovie->setParent( this );
	pMovies.append( aMovie );
}
	
const QList<KDCVTS*>& KDCDisc::vts() const
{
	return pVts;
}

const QList<KDCMovie*>& KDCDisc::movies() const
{
	return pMovies;
}

KDCMenu* KDCDisc::menu() const
{
	return pMenu;
}

int KDCDisc::id() const
{
	return pId;
}

KDCDiscSettings* KDCDisc::settings() const
{
	return pSettings;
}
	
void KDCDisc::remove( KDCVTS *aVts )
{
	aVts->setParent( NULL );
	pVts.removeOne( aVts );
}

void KDCDisc::remove( KDCMenu *aMenu )
{
	aMenu->setParent( NULL );
	pMenu = NULL;
}

void KDCDisc::remove( KDCMovie *aMovie )
{
	aMovie->setParent( NULL );
	pMovies.removeOne( aMovie );
}

quint64 KDCDisc::size() const
{
	quint64 res = 0;
	foreach ( KDCMovie *movie, pMovies )
		res += movie->size();
	return res;
}
